Next | Prev | Up | Top | Contents | Index

Obtaining Basic Block Counts

Use this procedure to obtain basic block counts. Also refer to Figure 4-2, which illustrates how basic block counting works.

  1. Compile and link your program. Do not use the -p option. The following example uses the input file myprog.c.

    % cc -o myprog myprog.c

    The cc compiler compiles myprog.c into an executable called myprog.

  2. Run pixie to generate the equivalent program containing basic-block-counting code.

    % pixie myprog

    pixie takes myprog and writes an equivalent program, myprog.pixie, containing additional code that counts the execution of each basic block. pixie also writes an equivalent program for each shared object used by the program (in the form: libname.so.pixie), containing additional code that counts the execution of each basic block. For example, if myprog uses libc.so.1, pixie generates libc.so.1.pixie.

  3. Set the path for your .pixie files. pixie uses the rld search path for libraries (see rld(1) for the default paths). If the .pixie files are in your local directory, set the path as:

    % setenv LD_LIBRARY_PATH .

  4. Execute the file(s) generated by pixie (myprog.pixie) in the same way you executed the original program.

    % myprog.pixie

    This program generates a list of basic block counts in files named myprog.Counts. If the program executes a fork/sproc, a process ID is appended to the end of the filename (for example, myprog.Counts.345) for each process.

  5. Run the profile formatting program prof specifying the -pixie option and the name of the original program.

    % prof -pixie myprog myprog.Counts

    prof extracts information from myprog.Counts and prints it in an easily readable format. If multiple .Counts files exist, you can use the wildcard character (*) to specify all of the files.

    % prof -pixie myprog myprog.Counts*

Note: Specifying myprog.Counts is optional; prof searches by default for names having the form prog_name.Counts. You can run the program several times, altering the input data, to create multiple profile data files. See "Example Using prof -pixie -dis" later in this section for an example.

The time computation assumes a "best case" execution; actual execution may take longer. This is because the time includes predicted stalls within a basic block, but not actual stalls that may occur entering a basic block. Also it assumes that all instructions and data are in cache (for example, it excludes the delays due to cache misses and memory fetches and stores).

The complete output of the -pixie option is often extremely large. Use the -quit option with prof to restrict the size of the output. Refer to "Running the Profiler" for details about prof options.

Include or exclude information on specific procedures within your program by using the prof options -only or -exclude (explained in Table 4-1). prof timings reflect only time spent in a specific procedure, not time spent including procedures called by that procedure. The CASEVision/WorkShop toolset, an optional software product, can show an estimate of inclusive times.

Figure 4-2 : How Basic Block Counting Works


Next | Prev | Up | Top | Contents | Index